package com.heima.wemedia.controller;

import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentManageDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.CommentManageService;
import lombok.extern.slf4j.Slf4j;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.comment.dtos.CommentConfigDto;
import com.heima.model.comment.dtos.CommentNewsQueryDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.CommentManageService;
import org.apache.ibatis.annotations.Delete;
import org.simpleframework.xml.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author luoTao
 * @project xmsz
 * @date 2024/1/27 16:26:05
 * 自媒体端评论管理
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/comment/manage")
public class CommentManageController {
    @Autowired
    private CommentManageService commentManageService;
    /**
     * @author 18297
     * @date 2024/1/27 16:37
     * @description 回复评论
     * @param dto:
     * @return ResponseResult
     */
    @PostMapping("/comment_repay")
    public ResponseResult<?> saveCommentRepay(@RequestBody CommentRepaySaveDto dto){
        log.info("作者回复评论方法");
        return commentManageService.saveCommentRepay(dto);
    }
    /**
     * @author 18297
     * @date 2024/1/27 22:54
     * @description 作者点赞评论
     * @param dto:
     * @return ResponseResult
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        log.info("作者点赞评论");
        return commentManageService.like(dto);
    }

    @PostMapping("/find_news_comments")
    public PageResponseResult findNewsComment(@RequestBody CommentNewsQueryDto dto){
        return commentManageService.findNewsComment(dto);
    }

    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult deleteComment(@PathVariable String commentId){
        return commentManageService.deleteComment(commentId);
    }

    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult deleteCommentRepay(@PathVariable String commentRepayId){
        return commentManageService.deleteCommentRepay(commentRepayId);
    }
    /**
     * 功能描述：评论开启和关闭
     *
     * @param dto
     * @return {@link ResponseResult }
     * @author sungang
     * @date 2024/01/27  23:16
     */

    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody CommentConfigDto dto){
        return commentManageService.updateCommentStatus(dto);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody CommentManageDto commentManageDto){
        return commentManageService.list(commentManageDto);
    }
}
